const { View , Text , Button} = require("@tarojs/components");
import './MyReport.less'
import http from '../../../../utils/http'
import Taro , {useReady} from '@tarojs/taro'
import React, { useState} from 'react'

function MyReport (){

    const [arr,setArr]=useState([])

    useReady(() => {
        http({   //获取我的体检详细
            url:"/getreport",
            data:{
                user_tel:15184462493,
				order_status:2
            },
            header:{
                'content-type': 'application/json' 
            },
        }).then((res)=>{
            setArr(res)     
        })
      })

    const look=(b)=>{
        Taro.navigateTo({
            url:'/pages/HXM/LookReport/LookReport?id='+b,
        })
    }

     const fromData=(a)=>{   //后台传前台时间格式转换
        let time = new Date(a)
        let month = time.getMonth() + 1 
        let date = time.getDate()
        let hours = time.getHours()
        let minutes = time.getMinutes()
        // let second = time.getSeconds() // 获取秒数
        // 小于10前加一个0
        if(month < 10) {
          month = '0' + month
        }
        if(date < 10) {
          date = '0' + date
        }
        return time.getFullYear() + '-' + month + '-' + date 
    }

 return(
    <View>
        {arr.map((v,i)=>(
            <View  className="view1">
                <View className="view1-1">{v.org_Name}</View>
                <View className="view1-2">
                    <View className="v1">
                        <Text>
                            <Text>{v.user_name} </Text>
                            <Text> {v.user_tel}</Text>
                        </Text>
                        <Text>
                            <Text>体检时间</Text>
                            <Text>{fromData(v.order_date)}</Text>
                        </Text>
                    </View>
                    <View className="v2">
                        <View>
                            <Button type="primary" plain="true" onClick={look.bind(this,v.order_orderId)}>查看</Button>
                        </View>
                    </View>
                </View>
            </View>))
        }
    </View>   
 )
}
export default MyReport